package com.mustafaiev.tair.cts.tapestry.message;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.tapestry5.ioc.annotations.Inject;

/**
 * @author tair
 * 
 */
public class CostTrackingSystemMessageService implements
        ICostTrackingSystemMessageService {

    @Inject
    private MessagesMap messagesMap;

    private final static List<String> MESSAGE_KEYS = new ArrayList<String>();

    public void addMessage(final String messageKey) {
        MESSAGE_KEYS.add(messageKey);
    }

    public void addMessage(final String messageKey,
            final MessageLevel messageLevel) {
        // TODO Implement later!
    }

    public String getMessage(final String messageKey) {
        final Map<String, String> map = messagesMap.getMessagesMap();
        String message = "";
        if ((map != null) && (map.get(messageKey) != null)) {
            message = map.get(messageKey);
        }
        return message;
    }

    public List<String> getMessages() {
        final List<String> messages = new ArrayList<String>();
        for (final String key : MESSAGE_KEYS) {
            messages.add(getMessage(key));
        }
        return messages;
    }

}
